﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
    public class LoaiMonDAO
    {
        public static DataTable ListLoaimon()
        {
            string sql = string.Format("select * from LOAIMON");
            return DataProvider.ExcuteQuery(sql);
        }
        public static int ThemLoaimon(LoaimonDTO loaimon)
        {
            string sql = string.Format("insert into LOAIMON(TENLOAI) value(N'{0}')", loaimon.Tenloai);
            return DataProvider.ExcuteNonQuery(sql);
        }
        public static DataTable Tenloai(int maloai)
        {
            string sql = string.Format("select TENLOAI from LOAIMON WHERE MALOAI={0}", maloai);
            return DataProvider.ExcuteQuery(sql);
        }
        public static int XoaMon(int Maloai)
        {
            string sql = string.Format("delete LOAIMON where MALOAI={0}",Maloai);
            return DataProvider.ExcuteNonQuery(sql);
        }
        public static int Capnhat(LoaimonDTO loaimon)
        {
            string sql = string.Format("update LOAIMON set TENLOAI='{0}' where MALOAI='{1}'", loaimon.Tenloai, loaimon.Maloai);
            return DataProvider.ExcuteNonQuery(sql);
        }
    }
}
